<?php
/** [后台权限验证控制器]
 * @Author: 976123967@qq.com
 * @Date:   2015-01-09 16:59:21
 * @Last Modified by:   chenli
 * @Last Modified time: 2015-03-01 00:08:16
 */
class PublicAction extends ExtendAction
{
	public function _initialize()
	{
		// 验证是否登录
		if(!isset($_SESSION['uid']) || !isset($_SESSION['username']))
		{
			$this->redirect('Login/index');
		}
		
		// 验证是否锁定
		$user = D("User")->where(array('username'=>$_SESSION['username']))->find();
		if($user['lock'])
		{
			$this->redirect("Login/out");
		}

		// 验证是不是管理员
		if(!isset($_SESSION['roleinfo']) || $_SESSION['roleinfo']!=1)
		{
			$this->redirect("Login/out");
		}


		// 验证权限
		
		if(!in_array(session('uid'), C('auth_superadmin')) && in_array(ACTION_NAME,C('auth_action_name')))
		{
			// 权限验证
			import('ORG.Util.Auth');
			$auth = new Auth();
			if(!$auth->check(strtolower(GROUP_NAME . '-' . MODULE_NAME . '-' . ACTION_NAME),session('uid')))
					die('您没有相关权限！');

		}
	}
}